package com.gw.vip.server.service.dao_service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gw.vip.server.dao.ShopInfoMapper;
import com.gw.vip.server.po.ShopInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author GW
 * @description
 * @since 2022-05-03
 */
@Service
public class ShopInfoService extends ServiceImpl<ShopInfoMapper, ShopInfo> {
    public IPage<ShopInfo> shopInfoList(String shopId, String name, long current, long size) {
        QueryWrapper<ShopInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(StringUtils.isNotBlank(shopId), ShopInfo::getId, shopId);
        queryWrapper.lambda().like(StringUtils.isNotBlank(name), ShopInfo::getName, name);
        queryWrapper.select().orderByDesc("crt_time");
        Page<ShopInfo> page = new Page<>(current, size);
        return page(page, queryWrapper);
    }
}
